<script>
	export default {
		globalData: {
			square: 'first'
		},
		onLaunch: function() {
			// console.log('App Launch')
			uni.addInterceptor('navigateTo', {
				// 页面跳转前进行拦截, invoke根据返回值进行判断是否继续执行跳转
				invoke() {
					var token = uni.getStorageSync('token')
					if (token === undefined || token == '' || token === null) {
						uni.showToast({
							title: '未登录，请先登录',
							icon: 'none'
						})
						setTimeout(() => {
							uni.redirectTo({
								url: '/pages/login/login'
							})
						}, 2000)
						return false
					}
					return true
				},
				success(e) {}
			})
			uni.addInterceptor('switchTab', {
				// tabbar页面跳转前进行拦截
				invoke() {
					var token = uni.getStorageSync('token')
					if (token === undefined || token == '' || token === null) {
						uni.redirectTo({
							url: '/pages/login/login'
						})
						return false
					}
					return true
				},
				success(e) {}
			})
			uni.hideTabBar({
				animation: false
			})
		},
		onShow: function() {
			uni.hideTabBar({
				animation: false
			})
		},
		onHide: function() {
			// console.log('App Hide')
			uni.hideTabBar({
				animation: false
			})
		},

	}
</script>

<style lang="scss">
	@import "uview-ui/index.scss";
	@import "@/static/icon/iconfont.css";
</style>
